using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Drawing;
using DevExpress.XtraEditors;

namespace THSLib
{
    public enum ProgressStatus { InProgress = 1, Complete = 2 };

    public class ProgressEventArgs : EventArgs
    {
        private ProgressStatus _status;

        public ProgressStatus Status
        {
            get
            {
                return _status;
            }
        }

        public ProgressEventArgs(ProgressStatus status)
        {
            _status = status;
        }
    }

    public delegate void ProgressEventHandler(object sender, ProgressEventArgs e);
    
    public class THSProgressBar
    {
        private static Thread THSProgressThread;
        private static guiTHSProgressBar _guiTHSProgressBar = null;
        public static string THSText = "";

        public static void Start(string startString)
        {
            Cursor.Current = Cursors.WaitCursor;
            if (_guiTHSProgressBar == null)
                _guiTHSProgressBar = new guiTHSProgressBar();
            _guiTHSProgressBar.Show(startString + "...");
            Application.DoEvents();
        }

        public static void Start()
        {
            THSProgressBar.Start("");
        }

        //static void ShowTHSProgress(object obj)
        //{
        //    if (_guiTHSProgressBar == null)
        //    {
        //        _guiTHSProgressBar = new guiTHSProgressbar(obj.ToString());
        //        _guiTHSProgressBar.THSTimerStart();
        //        Application.Run(_guiTHSProgressBar);
        //    }
        //    else
        //    {
        //        _guiTHSProgressBar.Activate();
        //        _guiTHSProgressBar.Show();
        //    }
        //}

        public static void SetTHSText(string strText)
        {
            if (_guiTHSProgressBar != null)
                _guiTHSProgressBar.Show(strText + "...");
        }

        public static void Close()
        {
            Cursor.Current = Cursors.Default;
            if (_guiTHSProgressBar != null)
                _guiTHSProgressBar.Hide();
        }
    }
}
